package com.example.jurisdiction.Controller;

import java.io.File;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


import com.example.jurisdiction.Service.pageService;
import entity.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.springframework.web.servlet.ModelAndView;

@CrossOrigin(methods = {RequestMethod.POST,RequestMethod.GET})
@Controller
@RequestMapping("/roles")
public class pageContoller{//new

		@Autowired
	private pageService rolesService;

	//用户
	@RequestMapping("/select.do")  
	public @ResponseBody
	PageBean list(PageBean pageBean, HttpServletResponse response, HttpSession session)throws Exception{
	    //response.setHeader("Access-Control-Allow-Origin", "*");
		
		System.out.println("login:sessionid:"+session.getId());
		System.out.println("开始"+pageBean.getCurrentPage()+"结束"+pageBean.getPageSize());
	    return this.rolesService.getAllUser(pageBean.getCurrentPage(), pageBean.getPageSize(),pageBean.getName());
	
	}
	
	//角色
		@RequestMapping("/get.do")  
		public @ResponseBody PageBean lists(PageBean pageBean,HttpServletResponse response,HttpSession session)throws Exception{
		    //response.setHeader("Access-Control-Allow-Origin", "*");
			
			System.out.println("login:sessionid:"+session.getId());
			System.out.println("开始"+pageBean.getCurrentPage()+"结束"+pageBean.getPageSize());
		    return this.rolesService.getAllRole(pageBean.getCurrentPage(), pageBean.getPageSize(),pageBean.getName());
		
		}
		
		//菜单
				@RequestMapping("/getjurisdiction.do")  
				public @ResponseBody PageBean getjurisdiction(PageBean pageBean,HttpServletResponse response,HttpSession session)throws Exception{
				    //response.setHeader("Access-Control-Allow-Origin", "*");
					
					System.out.println("login:sessionid:"+session.getId());
					System.out.println("开始"+pageBean.getCurrentPage()+"结束"+pageBean.getPageSize());
				    return this.rolesService.getAlljurisdiction(pageBean.getCurrentPage(), pageBean.getPageSize(),pageBean.getName());
				
				}
	
}
